'use strict'

define([ 'jquery', 'bootstrap', 'select2', 'shiftform', 'validate',
    'validate.en', 'datetimepicker'], function($) {
  return {
    init : function() {
      //this.onSubmitForm();
      this.initPage();
      this.initModal();
    },
    
    initPage: function() {
      $(document).on("click", ".career-workbook-select", function() {
        $(this).parents("tr").find(".career-workbook-select").removeClass("active");
        $(this).addClass("active");
      })
    },
    
    initModal: function() {
      $(document).on("shown.bs.modal", "#career-worbook-start", function(e) {
        $(e.currentTarget).find(".start-btn").on("click", function() {
          window.location.href = window.__CTX__.root + "/sessions/1/delegate-preparations/career-workbook/information"
        })
      })
    },
    
    onSubmitForm: function() {
      var that = this
              
      $(e.currentTarget).find('form[data-validate="true"]').bt_validate()  //bind validate
        
      var $form = $(document).find("form")                          //bind shiftform
      $form.shiftform({
        beforeSubmit : function(el) {
          $form.trigger("validate.ajax.submit");
          return $.bt_validate.result[$.bt_validate.form_id]
        }
      })
    }
  }
})
